<?php namespace Home\Controller;
use Hdphp\Controller\Controller;
class MemberController extends Controller{
	//注册
    public function reg(){
    	if(IS_AJAX){
//  		p(Q('post.'));
            $qUser = new \Common\Model\QUser;
            if(!$qUser->store()){
                $this->ajax(['status'=>false,'message'=>$qUser->getError()]);
            }else{
                $this->ajax(['status'=>true,'message'=>'注册成功']);
            }
        }
        View::make();
    }
	
	//登陆
    public function login(){
    	if(IS_AJAX){
    		$login= new \Common\Model\Login;
			if(!$login->login()){
				$this->ajax(['status'=>false,'message'=>$login->getError()]);
			}else{
				$qusername=Q('post.qusername');
				$_SESSION['qusername']=$qusername;
				$this->ajax(['status'=>true,'message'=>'登陆成功']);
			}
    	}
        View::make();
    }
	
	//退出
    public function out(){
		session_unset();
		session_decode();
		go(U("退出成功",array('')));
    }
	
	//验证码
    public function code(){
        Code::make();
    }
}